<?php

class qqqController extends commonController
{
    //接口秘钥
const apikey = 'm1pa7mhCb1CX1aqeliNkJDHVa0V3zWJb';
//s.click淘宝客短连接解析商品id接口
const apiurl = "http://api.tbk.dingdanxia.com/waimai/meituan_privilege";

public function getaaAction(){
    //开始调用
    $result = $this->curl_post(self::apiurl, array(
        //接口秘钥
        "apikey"    => self::apikey,
        //渠道方用户唯一标识,渠道可自定义,长度不超过50，参数中不能包含dingdanxia，用于向用户返佣,支持小写字母和数字的格式,其它字符可能造成无法正常跟单
        "sid"        => "1234"
    ));


//打印结果
    var_dump($result);
}


    /**
     * post请求
     * @param string $url
     * @param array $params
     * @param int $timeout
     */
    function curl_post($url, $params, $timeout = 3) {
//        echo '<pre>';
//        var_dump($url);
//        var_dump($params);die;
        try {
            foreach ($params as $key => $val) {
                $post[] = "{$key}={$val}";
            }
            $post_data  = implode('&', $post);
            $ch = curl_init();
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
            return curl_exec($ch);
        }
        catch (Exception $e) {
            return false;
        }
    }
}